﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace ScanSnap.Domain.TreeData
{
    [System.Runtime.Serialization.DataContract]
    public class OrganizationTree
    {
        [System.Runtime.Serialization.DataMember(Name = "attr")]
        public Attr attr { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "children")]
        public List<TreeDocType> children { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "data")]
        public Data data { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "icon")]
        public object icon { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "id")]
        public string id { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "state")]
        public string state { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "title")]
        public string title { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "type")]
        public object type { get; set; }

        public void ToString2()
        {
            Debug.WriteLine("Attr.Id  : " + attr.id + "  Data.Title  : " + data.title );
            foreach (TreeDocType obj in children)
            {
                Debug.WriteLine("           Children : TreeDocType");
                Debug.WriteLine("               Attr.Id  : " + obj.attr.id + "  Data.Title  : " + obj.data.title );
                foreach (TreeMstDoc obj2 in obj.children)
                {
                    Debug.WriteLine("                       Children : TreeMstDoc");
                    Debug.WriteLine("                           Attr.Id  : " + obj2.attr.id + "  Data.Title  : " + obj2.data.title );
                    foreach (TreeUserDoc obj3 in obj2.children)
                    {
                        Debug.WriteLine("                                   Children : TreeUserDoc");
                        Debug.WriteLine("                                       Attr.Id  : " + obj3.attr.id + "  Data.Title  : " + obj3.data.title );
                    }
                }
            }
        }
    }

    [System.Runtime.Serialization.DataContract]
    public class TreeDocType
    {
        [System.Runtime.Serialization.DataMember(Name = "attr")]
        public Attr attr { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "children")]
        public List<TreeMstDoc> children { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "data")]
        public Data data { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "icon")]
        public object icon { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "id")]
        public string id { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "state")]
        public string state { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "title")]
        public string title { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "type")]
        public object type { get; set; }
    }

    [System.Runtime.Serialization.DataContract]
    public class TreeMstDoc
    {
        private List<TreeUserDoc> _children;
        private Boolean hasChildren = false;
        [System.Runtime.Serialization.DataMember(Name = "attr")]
        public Attr attr { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "children")]
        public List<TreeUserDoc> children
        {
            get
            {
                return this._children;
            }
            set
            {
                this._children = value;
                if (this._children.Count > 0)
                {
                    this.hasChildren = true;
                }

            }
        }
        [System.Runtime.Serialization.DataMember(Name = "data")]
        public Data data { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "icon")]
        public object icon { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "id")]
        public string id { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "state")]
        public string state { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "title")]
        public string title { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "type")]
        public object type { get; set; }

        public Boolean HasChildren
        {
            get
            {
                return this.hasChildren;
            }
            set
            {
                this.hasChildren = value;
            }
        }


    }

    [System.Runtime.Serialization.DataContract]
    public class TreeUserDoc
    {
        [System.Runtime.Serialization.DataMember(Name = "attr")]
        public Attr attr { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "children")]
        public List<object> children { get; set;}

        [System.Runtime.Serialization.DataMember(Name = "data")]
        public Data data { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "icon")]
        public object icon { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "id")]
        public string id { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "state")]
        public string state { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "title")]
        public string title { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "type")]
        public object type { get; set; }

        public Boolean hasItems{get; set;}


    }

    [System.Runtime.Serialization.DataContract]
    public class Attr
    {
        [System.Runtime.Serialization.DataMember(Name = "id")]
        public string id { get; set; }
    }

    [System.Runtime.Serialization.DataContract]
    public class Data
    {
        [System.Runtime.Serialization.DataMember(Name = "title")]
        public string title { get; set; }

        [System.Runtime.Serialization.DataMember(Name = "icon")]
        public string icon { get; set; }
    }

    
}
